package cn.mw.cmdb.view;

import cn.mw.cmdb.entity.ModelGroupInfo;
import cn.mw.cmdb.entity.ModelInfo;
import cn.mw.cmdb.entity.ModelTemplateInfo;
import cn.mw.cmdb.mongoMapper.ModelGroupInfoMapper;
import cn.mw.cmdb.mongoMapper.ModelInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Component
@Service
public class TemplateTableConverter implements ViewConvert<ModelTemplateInfo, TemplateTableView> {

//    private ModelInfoMapper custModelMapper;
//    private ModelGroupInfoMapper modelGroupInfoMapper;
//    @Autowired
//    public TemplateTableConverter(ModelInfoMapper custModelMapper, ModelGroupInfoMapper modelGroupInfoMapper) {
//        this.custModelMapper = custModelMapper;
//        this.modelGroupInfoMapper = modelGroupInfoMapper;
//    }

    @Override
    public TemplateTableView convert(ModelTemplateInfo param ,ViewConvertContext context) {
        TemplateTableView view = new TemplateTableView();
//        ModelInfo modelInfo = custModelMapper.findById(param.getModelId());
//        ModelGroupInfo groupInfo = modelGroupInfoMapper.findById(param.getModelGroupId());
//        view.extractFromModelInfo(param);
//        if(modelInfo!=null){
//            view.setModelName(modelInfo.getModelName());
//        }
//        if(groupInfo!=null){
//            view.setModelGroupName(groupInfo.getName());
//        }
        view.extractFromModelInfo(param);
        return view;
    }
}
